﻿@{ Layout = "~/Views/Shared/_FormWhite.cshtml"; }

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a data-toggle="tab" href="#tab-1" aria-expanded="true"> 档案封箱</a>
                </li>
                <li class="">
                    <a data-toggle="tab" href="#tab-2" aria-expanded="false">重打盒码、箱码</a>
                </li>
            </ul>
            <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-sm-3 control-label ">档案类别：</label>
                            <div class="col-sm-8 select2" id="archive-type" col="ArchiveType">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label ">档案年份：</label>
                            <div class="col-sm-8 select2" id="archive-year" col="ArchiveYear">
                            </div>
                        </div>
                        <div class="form-group">
                            @*revised by MYL 2021-7-7*@
                            <label class="col-sm-3 control-label ">档案号：</label>
                            <div style="display:flex">
                                <div class="col-sm-5">
                                    <input id="archive-id-start" col="ArchiveIdStart" onkeyup="checkContent(this)" type="text" class="form-control" onblur="" placeholder="输入起始档案号，例如如00001" />
                                </div>
                                <div>~</div>
                                <div class="col-sm-5">
                                    <input id="archive-id-end" col="ArchiveIdEnd" onkeyup="checkContent(this)" type="text" class="form-control" placeholder="输入起始档案号的截止号" />
                                </div>
                            </div>
                        </div>
                        <div class="form-group">

                            @*revised by MYL 2021-7-7*@
                            <label class="col-sm-3 control-label ">档案子号：</label>
                            <div style="display:flex">
                                <div class="col-sm-5">
                                    <input id="archive-id-start-child" col="ArchiveIdStartChild" onkeyup="checkContent(this)" type="text" class="form-control" placeholder="输入起始档案号的子号，例如：.01；也可为空" />
                                </div>
                                <div>~</div>
                                <div class="col-sm-5">
                                    <input id="archive-id-end-child" col="ArchiveIdEndChild" onkeyup="checkContent(this)" type="text" class="form-control" placeholder="输入一盒中截止子档案号，也可为空" />
                                </div>
                            </div>
                        </div>


                        <div class="row" style="text-align:center">
                            <div class="col-sm-5"></div>
                            <button id="focobtn" type="button" class="btn btn-outline btn-info visible col-sm-2" onclick="generateArcIds()">生成档案号列表</button>
                        </div>
                        <div id="focotable" class="row visible" align="center">
                            <div class="col-sm-auto" style="padding-top:10px;text-align:center">
                                <div class="panel panel-primary ">
                                    <div class="panel-heading">
                                        <big>档案号列表（您可以选择需要删除的档案）</big>
                                    </div>
                                    <div id="archiveids" class="panel-body" style="column-count:2">

                                    </div>
                                </div>
                            </div>
                        </div>

                      
                        @*<p>
                                <button type="button" id="btnGenerateBinCode" class="btn btn-block btn-outline btn-primary" onclick="resetPage()">reset page</button>
                            </p>*@

                        @*批量打印*@
                        <div id="divBatch">
                            <div class="form-group">
                                <div class="col-sm-12" id="divBatch">

                                    <h3 class="font-weight-bold">
                                        <span id="curbincode" col="CurBinCode"></span>
                                        <span class="hidden" id="entityid" col="EntityId"></span>

                                    </h3>
                                    <p>
                                        <button type="button" id="btnPrintBinCode" class="btn btn-block btn-outline btn-primary" onclick="BatchprintBoxCode()">批量打印</button>
                                    </p>
                                </div>
                            </div>
                        </div>

                        <div id="divBottom">
                            <div class="form-group">
                                <div class="col-sm-12" id="divBinCode">

                                    <h3 class="font-weight-bold">
                                        <span id="curbincode" col="CurBinCode"></span>
                                        <span class="hidden" id="entityid" col="EntityId"></span>
                                        <span class="hidden" id="arcIds" col="ArcIds"></span>
                                    </h3>
                                    <p>
                                        <button type="button" id="btnPrintBinCode" class="btn btn-block btn-outline btn-primary" onclick="printBinCode()">打印箱码</button>
                                    </p>
                                </div>
                            </div>

                            <div id="divSecure">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">输入箱密码（箱码打印后，以下区域才显示）：</label>
                                    <div class="col-sm-8">
                                        <input id="binsecure" col="BinSecure" type="text" class="form-control" placeholder="输入箱密码" />
                                    </div>
                                </div>
                                <p>
                                    <button type="button" class="btn btn-block btn-outline btn-primary" onclick="setBinSecret()">完成，继续</button>
                                </p>
                            </div>
                        </div>

                    </div>
                </div>

                <div id="tab-2" class="tab-pane">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-sm-4">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title  gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <button type="button" class="btn btn-w-m btn-primary">批量打印</button>
                                        <h5 class="font-bold">Z21-2019-X-00001</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00001</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00002</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00003</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00004</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00005</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00006</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00007</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00008</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00009</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00010</a>
                                    </div>
                                </div>
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00002</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00011</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00012</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00013</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00014</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00015</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00016</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00017</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00018</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00019</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00020</a>
                                    </div>
                                </div>
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00003</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00021</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00022</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00023</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00024</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00025</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00026</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00027</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00028</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00029</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00030</a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00004</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00031</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00032</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00033</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00034</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00035</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00036</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00037</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00038</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00039</a>
                                        <a class="btn btn-success btn-rounded" href="#">Z21-2019-H-00040</a>
                                    </div>
                                </div>
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00005</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">


                                    </div>
                                </div>
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00006</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">


                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00007</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">


                                    </div>
                                </div>
                                <div class="ibox">
                                    <div class="ibox-title  gray-bg ">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00008</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">


                                    </div>
                                </div>
                                <div class="ibox">
                                    <div class="ibox-title   gray-bg">
                                        <a class="fa fa-print pull-right"></a>
                                        <h5 class="font-bold">Z21-2019-X-00009</h5>
                                    </div>
                                    <div class="ibox-content   gray-bg">


                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </form>
</div>

<script type="text/javascript">

    $("#divSecure").css("visibility", "hidden");
    $('#collapseTwo').collapse('show');
    $('#focobtn').attr('disabled', true);
    $("#focotable").css("visibility", "hidden");
    $("#divBatch").css("visibility", "hidden");

    function print(code) {
        var flag;
        if (code.indexOf("-H-") > 0) flag = "盒码";
        else flag = "箱码";

        ys.confirm("确定要重打" + flag + ":" + code + "吗？", function () {
                ys.ajax({
                    url: '@Url.Content("~/StorageManage/BarLib/ReprintCode")' + '?code=' + code,
                    type: "post",
                    success: function (obj) {
                        if (obj.Tag == 1) {
                            ys.msgSuccess(obj.Message);
                        }
                        else {
                            ys.msgError(obj.Message);
                        }
                    }
                });
            });
    }

    $(function () {
        var data = [
            { 'Key': '2020', 'Value': '2020' },
            { 'Key': '2019', 'Value': '2019' },
            { 'Key': '2018', 'Value': '2018' },
            { 'Key': '2017', 'Value': '2017' },
            { 'Key': '2016', 'Value': '2016' },
            { 'Key': '2015', 'Value': '2015' },
            { 'Key': '2014', 'Value': '2014' },
            { 'Key': '2013', 'Value': '2013' },
            { 'Key': '2012', 'Value': '2012' },
            { 'Key': '2011', 'Value': '2011' },
            { 'Key': '2010', 'Value': '2010' },
            { 'Key': '2009', 'Value': '2009' },
            { 'Key': '2008', 'Value': '2008' },
            { 'Key': '2007', 'Value': '2007' },
            { 'Key': '2006', 'Value': '2006' },
            { 'Key': '2005', 'Value': '2005' },
            { 'Key': '2004', 'Value': '2004' },
            { 'Key': '2003', 'Value': '2003' },
            { 'Key': '2002', 'Value': '2002' },
            { 'Key': '2001', 'Value': '2001' },
            { 'Key': '2000', 'Value': '2000' }
        ];

        var groupData = [
            {
                'Key': '规划类',
                'Value': [
                    { 'Key': 'Z49', 'Value': 'Z49' },
                    { 'Key': 'Z21', 'Value': 'Z21' },
                    { 'Key': 'Z22', 'Value': 'Z22' },
                    { 'Key': 'Z41', 'Value': 'Z41' },
                    { 'Key': 'Z43', 'Value': 'Z43' },
                    { 'Key': 'Z44', 'Value': 'Z44' },
                    { 'Key': 'ZQ', 'Value': 'ZQ' }
                ]
            },
            {
                'Key': '国土类',
                'Value': [
                    { 'Key': 'Z31', 'Value': 'Z31' },
                    { 'Key': 'Z32', 'Value': 'Z32' },
                    { 'Key': 'Z33', 'Value': 'Z33' },
                    { 'Key': 'Z34', 'Value': 'Z34' },
                    { 'Key': 'Z35', 'Value': 'Z35' },
                    { 'Key': 'Z36', 'Value': 'Z36' },
                    { 'Key': 'Z37', 'Value': 'Z37' },
                    { 'Key': 'Z38', 'Value': 'Z38' },
                    { 'Key': 'ZG', 'Value': 'ZG' },
                    { 'Key': 'ZT', 'Value': 'ZT' },
                    { 'Key': 'ZC', 'Value': 'ZC' },
                    { 'Key': 'ZJ', 'Value': 'ZJ' },
                    { 'Key': 'ZB', 'Value': 'ZB' },
                    { 'Key': 'ZH', 'Value': 'ZH' },
                    { 'Key': 'ZZ1', 'Value': 'ZZ1' },
                    { 'Key': 'ZZ2', 'Value': 'ZZ2' }
                ]
            },
            {
                'Key': '文书类',
                'Value': [
                    { 'Key': 'ZW', 'Value': 'ZW' },
                    { 'Key': 'ZW1', 'Value': 'ZW1' },
                    { 'Key': 'ZW2', 'Value': 'ZW2' }
                ]
            },
            {
                'Key': '房产类',
                'Value': [
                    { 'Key': 'Z51', 'Value': 'Z51' },
                    { 'Key': 'Z52', 'Value': 'Z52' },
                    { 'Key': 'Z54', 'Value': 'Z54' },
                    { 'Key': 'Z55', 'Value': 'Z55' },
                    { 'Key': 'Z56', 'Value': 'Z56' }
                ]
            },
            {
                'Key': '物业类',
                'Value': [
                    { 'Key': 'ZY', 'Value': 'ZY' },
                    { 'Key': 'ZY1', 'Value': 'ZY1' },
                    { 'Key': 'ZY2', 'Value': 'ZY2' },
                    { 'Key': 'ZY3', 'Value': 'ZY3' },
                    { 'Key': 'ZY4', 'Value': 'ZY4' },
                    { 'Key': 'ZY9', 'Value': 'ZY9' }
                ]

            },
            {
                'Key': '其他',
                'Value': [
                    { 'Key': 'ZQ', 'Value': 'ZQ' },
                    { 'Key': 'Z35', 'Value': 'Z35' },
                    { 'Key': 'ZT', 'Value': 'ZT' },
                    { 'Key': 'ZF1', 'Value': 'ZF1' },
                    { 'Key': 'ZFA3', 'Value': 'ZFA3' },
                    { 'Key': 'Z9221', 'Value': 'Z9221' },
                    { 'Key': 'Z9225', 'Value': 'Z9225' },
                    { 'Key': 'Z9226', 'Value': 'Z9226' },
                    { 'Key': 'Z9227', 'Value': 'Z9227' },
                    { 'Key': 'Z9211', 'Value': 'Z9211' },
                    { 'Key': 'Z9212', 'Value': 'Z9212' },
                    { 'Key': 'Z9213', 'Value': 'Z9213' },
                    { 'Key': 'Z9214', 'Value': 'Z9214' },
                    { 'Key': 'Z9215', 'Value': 'Z9215' },
                    { 'Key': 'Z9221', 'Value': 'Z9221' },
                    { 'Key': 'Z9222', 'Value': 'Z9222' },
                    { 'Key': 'Z9223', 'Value': 'Z9223' },
                    { 'Key': 'Z9311', 'Value': 'Z9311' },
                    { 'Key': 'Z9312', 'Value': 'Z9312' },
                    { 'Key': 'Z9313', 'Value': 'Z9313' },
                    { 'Key': 'Z9321', 'Value': 'Z9321' },
                    { 'Key': 'Z9351', 'Value': 'Z9351' },
                    { 'Key': 'Z9361', 'Value': 'Z9361' },
                    { 'Key': 'ZFB1', 'Value': 'ZFB1' },]
            },

        ];

        var CountBox;


        $("#archive-year").ysComboBox({
            data: data,
            class: "form-control"
        });

        $("#archive-type").ysComboBox({
            data: groupData,
            class: "form-control"
        });

        $('#form').validate({
            rules: {
                "archive-type": { required: true },
                "archive-year": {   required: true  },
                "archive-id-start": { required: true, digits: true },
                "archive-id-end": { digits: true },
                "archive-id-start-child": { digits: true },
                "archive-id-end-child": { digits: true },

            }
        });

    //    $("#divBottom").css("visibility", "hidden");

        init();
    });


    // 批量打印勾选框   created by XQ 2021-7-4
    var redioCount = 0;
    var x = document.getElementById('btnPrintBoxCode');
    $(document).ready(function () {

        if ($("#PrintWay").attr("checked") == "checked") redioCount = 1;
        $("input[type='checkbox']").click(function () {
            if (redioCount == 1) {
                $(this).removeAttr("checked");
                $("#divBatch").css("visibility", "hidden");
                x.innerHTML = '打印一个盒码';
                redioCount = 0;
            } else {
                $(this).attr("checked", "checked");
                $("#divBatch").css("visibility", "visible");
                x.innerHTML = '生成盒码';
                redioCount = 1;
            }
        });

    });

    //初始化
    function init() {
        ys.ajax({
            url: '@Url.Content("~/StorageManage/BarLib/GetReprintCodes")',
            type: 'post',
            data: { "frompage": "BarLib" },
            success: function (obj) {
                        if (obj.Tag == 1) {
                            $('#bin-box-list-for-reprint').html(obj.Result);
                        }
                        else {
                            ys.msgError(obj.Message);
                        }
                    }
                });
    }

    $("#archive-year").change(function () {
        $('#btnPrintBoxCode').prop("disabled", false);  // 启用
    /*这里是面向领域，自己新建一列用来传参*/
        var postData = $('#form').getWebControls();
        postData.frompage = "BarLib";
        console.log(postData);
        var selecttext = $('#archive-year').find("option:selected").text();
        console.log(selecttext);
        checkContent();

         ys.ajax({
                    url: '@Url.Content("~/StorageManage/BarLib/GetBoxCodesListNotFinished")',
                    type: 'post',
                    data: postData,
                    success: function (obj) {
                        if (obj.Tag == 1) {
                            var defaultData = {};
                            defaultData.Description = obj.Description;

                            $('#collapseTwo').setWebControls(defaultData);

                            $('#collapseTwo').collapse('show');

                            //if (obj.TotalCount == 10) {  //未归属到 箱码 的盒码数达到10个， 禁止 打印盒码  按钮，必须要打印 箱码
                            //    $('#btnPrintBoxCode').prop("disabled", true);  // 禁用

                            //    $("#divBottom").css("visibility", "visible");
                            //    $("#divSecure").css("visibility", "hidden");
                            //}
                            //else {
                            //    $("#divBottom").css("visibility", "hidden");
                            //    $("#divSecure").css("visibility", "hidden");

                            //    $('#btnPrintBoxCode').prop("disabled", false);  // 启用
                            //}
                        }
                        else {
                            ys.msgError(obj.Message);
                        }
                    }
                });
    });


    //created by LJK 2021-7-7

    //如果四个框都有数据，显示建表按钮

    function checkContent() {
        var postData = $('#form').getWebControls();
        var start = postData.ArchiveIdStart;
        var end = postData.ArchiveIdEnd;
        var start2 = postData.ArchiveIdStartChild;
        var end2 = postData.ArchiveIdEndChild;
        if (postData.ArchiveYear == "")
            ys.msgWarning("请选择档案年份。");

        var st = $('#archive-year').find("option:selected").text();
        console.log(st);

        if (start != '' && end != '' && start2 != '' && end2 != ''&& st !="请选择")
            $('#focobtn').attr('disabled', false);
        else
            $('#focobtn').attr('disabled', true);


    }

    //created by LJK 2021-7-7
    //初始化暂存表数组函数，生成档案号,填入数组

    String.prototype.padLeft = function (len, charStr) {
        var s = this + '';
        return new Array(len - s.length + 1).join(charStr || '') + s;
    }
    String.prototype.padRight = function (len, charStr) {
        var s = this + '';
        return s + new Array(len - s.length + 1).join(charStr || '');
    }

    //created by LJK 2021-7-6

    function generateArcIds() {
        var postData = $('#form').getWebControls();
        var start = parseInt(postData.ArchiveIdStart);
        var end = parseInt(postData.ArchiveIdEnd);
        var start2 = parseInt(postData.ArchiveIdStartChild);
        var end2 = parseInt(postData.ArchiveIdEndChild);

       var arr =[];
        console.log(arr);
        /*添加list的字段*/
        for (var i = start; i <= end; i++) {
            for (var j = start2; j <= end2; j++) {
                arr.push(postData.ArchiveType + "·" + postData.ArchiveYear + "·" + i.toString().padLeft(5, "0") + "·" + j.toString().padLeft(2, "0"));

            }
        }
        displaylist(arr);
        document.getElementById("arcIds").innerText = arr.toString();
    }

    //created by LJK 2021-7-7

  

    function displaylist(arr) {
        console.log(arr);

        var temp = "", id;
        var arrstr = arr.toString();
        console.log(arrstr);
        for (j = 0; j < arr.length; j++) {
            id = arr[j];
            if (j == 0)
                temp += "<div style='text-align: center;margin-top: 0px'>" + id.substring(9, 20) + "<a class='btn btn-danger  btn-sm' onclick='listdelete(\"" + id + "\",\"" + arrstr + "\")'>" + " <i class='fa fa-remove'></i></a></div>";
            else
                temp += "<div style='text-align: center;margin-top: 5px'>" + id.slice(9, 20) + "<a class='btn btn-danger  btn-sm' onclick='listdelete(\"" + id + "\",\"" + arrstr + "\")'>" + " <i class='fa fa-remove'></i></a></div>";

        }
         document.getElementById("arcIds").innerText = arrstr;
        console.log(temp);
        $("#archiveids").html(temp);
        if ($("#archiveids").html() == null || $("#archiveids").html().length == 0)
            $("#focotable").css("visibility", "hidden");
        else
            $("#focotable").css("visibility", "visible");

    }

    //created by LJK 2021-7-7
    //暂存表内删除点击函数，从数组中删除对应档案号，再次调用呈现函数，将数组绑定到页面

    function listdelete(id, arrstr) {
        ys.confirm("确认要删除选中的这条档案吗？", function () {
            var arr = new Array();

            arr = arrstr.split(",");

            arr.remove(id);

            displaylist(arr);
            document.getElementById("arcIds").innerText = arr;
        });
    }

    Array.prototype.remove = function (val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };


    // 显示年份 Created by MYL 2021-7-7
    function groupData() {
        var groupData = $('#form').getWebControls();
                    ys.ajax({
                        url: '@Url.Content("~/StorageManage/BarLib/groupData")',
                        type: 'post',
                        data: groupData,
                        success: function (obj) {
                            if (obj.Tag == 1) {
                                ys.msgSuccess(obj.Message);
                                var defaultData = {};
                                defaultData.CurBinCode = obj.Result;    // 后端返回的当前箱码
                                defaultData.EntityId = obj.Description;  // 后端返回的 实体 Id (主键)

                                $('#divBinCode').setWebControls(defaultData);
                                $("#divSecure").css("visibility", "visible");
                            }
                            else {
                                ys.msgError(obj.Message);
                            }
                        }
                    });

    }

    //打印盒码   changed by XQ 2021-7-2
    function printBoxCode() {

                if ($('#form').validate().form()) {
                    var postData = $('#form').getWebControls();

                    if (postData.ArchiveType == "") {
                        ys.alertWarning("请选择档案类别。");
                        return false;
                    }
                    if (postData.ArchiveYear == "") {
                        ys.msgWarning("请选择档案年份。");
                        return false;
                    }
                    if (postData.ArchiveIdStartChild == "" && postData.ArchiveIdEndChild != "") {
                        ys.msgWarning("档案子号起始号为空时不能填入档案子号截止号！");
                        return false;
                    }

                    postData.ArrayIds = document.getElementById("arcIds").innerText;

                    // 批量打印
                    if (redioCount == 0)
                        postData.PrintWay = 0;
                    else
                        postData.PrintWay = 1;

                    ys.ajax({
                        url: '@Url.Content("~/StorageManage/BarLib/PrintBoxCode")',
                        type: 'post',
                        data: postData,
                        success: function (obj) {
                            if (obj.Tag == 1) {
                                ys.msgSuccess(obj.Message);

                                var defaultData = {};
                                defaultData.Description = obj.Description;

                                $('#collapseTwo').setWebControls(defaultData);

                                $('#collapseTwo').collapse('show');
                                CountBox = obj.TotalCount;
                                if (obj.TotalCount == 10) {  //未归属到 箱码 的盒码数达到10个， 禁止 打印盒码  按钮，必须要打印 箱码
                                    $('#btnPrintBoxCode').prop("disabled", true);  // 禁用
                                }

                                //    $("#divBottom").css("visibility", "visible");
                                //    $("#divSecure").css("visibility", "hidden");
                                //}
                                //else {
                                //    $("#divBottom").css("visibility", "hidden");
                                //    $("#divSecure").css("visibility", "hidden");

                                //    $('#btnPrintBoxCode').prop("disabled", false);  // 启用
                                //}
                            }
                            else {
                                ys.msgError(obj.Message);
                            }
                        }
                    });
                }
     }


    //created by XQ 2021-7-2
    //批量打印盒码（不生成数据记录）
    function BatchprintBoxCode() {
        var boxcodes = document.getElementById('description').innerText;
        if (boxcodes == "") {
            ys.alertWarning("未生成盒码！");
            return false;
        }
           
        ys.ajax({
            url: '@Url.Content("~/StorageManage/BarLib/BatchPrintBoxCode")' + '?boxCodes=' + boxcodes,
                        type: 'post',
                        success: function (obj) {
                            if (obj.Tag == 1) {
                                ys.msgSuccess(obj.Message);
                            }
                            else {
                                ys.msgError(obj.Message);
                            }
                        }
                    });
    }


    //打印箱码
    function printBinCode() {
        if (CountBox < 10) {
            ys.confirm("盒码数为" +CountBox + "，确定要打印吗？", function () {
                if ($('#form').validate().form()) {
                    var postData = $('#form').getWebControls();
                    ys.ajax({
                        url: '@Url.Content("~/StorageManage/BarLib/PrintBinCode")',
                        type: 'post',
                        data: postData,
                        success: function (obj) {
                            if (obj.Tag == 1) {
                                ys.msgSuccess(obj.Message);
                                var defaultData = {};
                                defaultData.CurBinCode = obj.Result;    // 后端返回的当前箱码
                                defaultData.EntityId = obj.Description;  // 后端返回的 实体 Id (主键)

                                $('#divBinCode').setWebControls(defaultData);
                                $("#divSecure").css("visibility", "visible");
                            }
                            else {
                                ys.msgError(obj.Message);
                            }
                        }
                    });
                }

            });
        }
        else {
             if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls();
            ys.ajax({
                url: '@Url.Content("~/StorageManage/BarLib/PrintBinCode")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        var defaultData = {};
                        defaultData.CurBinCode = obj.Result;    // 后端返回的当前箱码
                        defaultData.EntityId = obj.Description;  // 后端返回的 实体 Id (主键)

                        $('#divBinCode').setWebControls(defaultData);
                        $("#divSecure").css("visibility", "visible");
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
        }

    }

     //为档案箱设置密码锁
    function setBinSecret() {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls();
            ys.ajax({
                url: '@Url.Content("~/StorageManage/BarLib/SetBinSecret")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);

                        resetPage();
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }

    //完成一个装箱过程后，重置页面 -- 保留上次的档案类型、年份
    function resetPage() {
        $("#divSecure").css("visibility", "hidden");
        //$("#divBottom").css("visibility", "hidden");

        $("#archive-id-start").val("");
        $("#archive-id-start-child").val("");
        $("#archive-id-end-child").val("");

        $("#archive-id-end").val("");

        $("#curbincode").html("");
        $("#entityid").html("");

        $("#description").html("");

        $('#btnPrintBoxCode').prop("disabled", false); // 禁用

   //     $("#collapseTwo").css("collapse", "hiden");
    }


</script>

